<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>函数参数</title>
    <script type="text/javascript">

        //每次调用函数，都重新创建默认值，每个函数调用的都是不同对象
        function fn1(obj1 = {name:"孙悟空"}) {
            console.log("obj1 = ",obj1)
            obj1.name="猪八戒"
            console.log("obj1 = ", obj1)
        }
        fn1()   //输出孙悟空，猪八戒
        fn1()   //输出孙悟空，猪八戒

        //调用的是同一个对象
        obj2 = {name:"孙悟空"}

        function fn2(obj1 = obj2){
            console.log("obj2 = ", obj2)
            obj2.name="猪八戒"
            console.log("obj2 = ", obj2)
        }
        fn2()
        fn2()
        
    </script>
</head>
<body>
    
</body>
</html>